def isAnagram(str1, str2): # DO NOT modify this line 
    word1=list(str1)
    word2=list(str2)
    for i in range(len(word1)):
        if word2.index(word1[i])==ValueError:
            return False
        else:
            if word1.count(word1[i])!=word2.count(word1[i]):
                return False
            else:
                continue
    return True# You can modify or delete this line

# === DO NOT modify the code below ===
def main():
    s1 = input()
    s2 = input()
    print(1 if isAnagram(s1, s2) else 0)
    
if __name__ == '__main__':
    main()
# === DO NOT modify the code above ===
